﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class OrderView : System.Web.UI.Page
{
    private SOAWebService.Service1 ser = new SOAWebService.Service1();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    protected void BindData()
    {
        GridView1.DataSource = ser.GetAllOrder();
        GridView1.DataBind();
    }
    //protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    //{
    //    string orderid = e.CommandArgument.ToString();
    //    Session["orderid"] = orderid;
    //    Response.Redirect("OrderDetail.aspx");
    //}
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (ddlState.SelectedValue == "" && txtID.Text.ToString() != "")
        {
            List<SOAWebService.Order> list = new List<SOAWebService.Order>();
            list.Add(ser.getOrderById(txtID.Text.ToString()));
            GridView1.DataSource = list;
        }
        else if (txtID.Text.ToString() == "" && ddlState.SelectedValue != "")
            GridView1.DataSource = ser.GetOrderByState(Int32.Parse(ddlState.SelectedValue));
        else if (txtID.Text.ToString() == "" && ddlState.SelectedValue == "")
            GridView1.DataSource = ser.GetAllOrder();
        else
            GridView1.DataSource = ser.GetOrderByInfo(txtID.Text.ToString(), Int32.Parse(ddlState.SelectedValue));
        GridView1.DataBind();
    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {


    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindData();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void GridView1_PageIndexChanged(object sender, EventArgs e)
    {
    }
}
